### Function Description

Query job execution log by host

### Request Parameters

#### Interface parameters

| Fields           | Type   | Required | Description                                                                                                 |
|------------------|--------|----------|-------------------------------------------------------------------------------------------------------------|
| bk_scope_type    | string | yes      | Resource scope type. Optional values: biz - Business，biz_set - Business Set                                 |
| bk_scope_id      | string | yes      | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID                 |
| bk_biz_id        | long   | yes      | Deprecated. Business ID. This field has been deprecated and replaced by the field bk_scope_type+bk_scope_id |
| job_instance_id  | long   | yes      | Job instance ID                                                                                             |
| step_instance_id | long   | yes      | Step instance ID                                                                                            |
| bk_cloud_id      | int    | no       | Target server BK-Net ID                                                                                     |
| ip               | string | no       | Destination server IP. ***Deprecated, it is recommended to use the bk_host_id parameter                     |
| bk_host_id       | string | no       | Host ID                                                                                                     |

### Example of request

- GET

```json
/api/v3/get_job_instance_ip_log?bk_scope_type=biz&bk_scope_id=1&job_instance_id=50&step_instance_id=100&bk_cloud_id=0&ip=127.0.0.1
```

### Example of responses

#### Script execution steps

```json
{
    "result": true,
    "code": 0,
    "data": {
        "log_type": 1,
        "bk_host_id": 101,
        "ip": "127.0.0.1",
        "bk_cloud_id": 0,
        "log_content": "[2018-03-15 14:39:30][PID:56875] job_start\n"
    },
    "job_request_id": "xxx"
}
```

#### File distribution steps

```json
{
    "result": true,
    "code": 0,
    "data": {
        "log_type": 2,
        "bk_host_id": 101,
        "ip": "127.0.0.1",
        "bk_cloud_id": 0,
        "file_logs": [
            {
                "mode": 1,
                "src_ip": {
                    "host_id": 102,
                    "bk_cloud_id": 0,
                    "ip": "127.0.0.2"
                },
                "src_path": "/data/1.log",
                "dest_ip": {
                    "bk_host_id": 101,
                    "bk_cloud_id": 0,
                    "ip": "127.0.0.1"
                },
                "dest_path": "/tmp/1.log",
                "status": 4,
                "log_content": "[2021-06-28 11:32:16] FileName: /tmp/1.log FileSize: 9.0 Bytes State: dest agent success download file Speed: 1 KB/s Progress: 100% StatusDesc: dest agent success download file Detail: success"
            },
            {
                "mode": 0,
                "src_ip": {
                    "bk_host_id": 102,
                    "bk_cloud_id": 0,
                    "ip": "127.0.0.2"
                },
                "src_path": "/data/1.log",
                "status": 4,
                "log_content": "[2021-06-28 11:32:16] FileName: /data/1.log FileSize: 9.0 Bytes State: source agent success upload file Speed: 1 KB/s Progress: 100% StatusDesc: source agent success upload file Detail: success upload"
            }
        ]
    },
    "job_request_id": "xxx"
}
```

**Return result description**

- The file distribution log returns the file upload task log of the source server in addition to the file download task
  log of the target server (mode=0)
- Dest_ip corresponds to the bk_Cloud_id/IP of the request parameter

{% include '_generic_response.md.j2' %}

#### data

| Fields      | Type   | Never null | Description                                                             |
|-------------|--------|------------|-------------------------------------------------------------------------|
| bk_cloud_id | int    | yes        | Target server cloud area ID                                             |
| ip          | string | yes        | Destination server IP address                                           |
| log_type    | int    | yes        | Log type. 1 - Script execution task log; 2 - File distribution task log |
| log_content | string | no         | Log content of job script output                                        |
| file_logs   | array  | no         | File distribution task log. See file_log for definition                 |

#### file_log

| Fields      | Type   | Never null | Description                                                                  |
|-------------|--------|------------|------------------------------------------------------------------------------|
| mode        | int    | yes        | Distribution mode. 0: Upload; 1: Download                                    |
| src_ip      | object | yes        | File source host IP. see ip for definition                                   |
| src_path    | string | yes        | Source file paths                                                            |
| dest_ip     | object | yes        | Distribute the target host IP, with value for mode=1. See ip for definition. |
| dest_path   | string | yes        | Target path, with value for mode=1                                           |
| status      | int    | yes        | Task status. 1-Waiting; 2-Uploading; 3-Downloading; 4- Success; 5- Failure   |
| log_content | string | yes        | File distribution log contents                                               |

#### ip

| Fields      | Type   | Never null | Description |
|-------------|--------|------------|-------------|
| bk_cloud_id | long   | yes        | BK-Net ID   |
| ip          | string | yes        | IP Address  |
| bk_host_id  | long   | yes        | Host ID     |
